﻿using System;
using System.Collections.Generic;
using System.Linq;
using EncuentraloSilverlight.Models;

namespace EncuentraloSilverlight.Web.Models
{
    public partial class Search
    {
        public bool IsValid
        {
            get { return (GetSearchRuleViolations().Count() == 0); }
        }
        public IEnumerable<RuleViolation> GetSearchRuleViolations()
        {
            if (Date == null || Date.HasValue==false)
                yield return new RuleViolation("Date not valid", "Date");
            if (Parameter==null)
                yield return new RuleViolation("Parameter required", "Parameter");
            if(SearchType == null|| (SearchType !=0&&SearchType!=1))
             yield return new RuleViolation("SearchType not valid", "SearchType");
            yield break;
        }


    }
}